package com.ice.work.moment.user.service.role;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.honeybee.cloud.framework.common.page.Page;
import com.ice.work.moment.facade.user.dto.RoleDTO;
import com.ice.work.moment.facade.user.mapper.RoleConvertMapper;
import com.ice.work.moment.facade.user.model.Role;
import com.ice.work.moment.facade.user.param.PageRoleParam;
import com.ice.work.moment.user.dao.role.RoleRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description
 * @Author DELL
 * @Create 2019-03-18
 * @Since 1.0.0
 */
@Service
public class RoleServiceImpl implements IRoleService {

    @Autowired
    private RoleRepository repository;

    @Override
    public Page<RoleDTO> page(IPage<Role> page, PageRoleParam param) {
        IPage<Role> roleIPage = repository.page(page, param);
        return RoleConvertMapper.INSTANCE.toDTO(roleIPage);
    }

    @Override
    public List<RoleDTO> findByType(Integer type) {
        List<Role> list = repository.findByType(type);
        return RoleConvertMapper.INSTANCE.toDTO(list);
    }
}
